<table class="easyui-datagrid" data-options="method:'GET',url:'authority',singleSelect:true" toolbar="#authorityToolbar"
       id="authorityTable">
    <thead>
    <tr>
        <th data-options="field:'',width: 100,checkbox:true"></th>
        <th data-options="field:'id',width: 300">编码</th>
        <th data-options="field:'name',width: 100">名称</th>
        <th data-options="field:'description',width: 100">描述</th>
        <th data-options="field:'method',width: 100">方法</th>
        <th data-options="field:'url',width: 100">路径</th>
        <th data-options="field:'menu',width: 100,formatter:value=>value?'是':'否'">菜单</th>
    </tr>
    </thead>
</table>
<div id="authorityToolbar">
    <a href="#" class="easyui-linkbutton" iconCls="icon-add" plain="true"
       onclick="$('#authorityAdd').dialog('open')">添加权限</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="
    var selected = $('#authorityTable').datagrid('getSelected');
    if (!selected){
        $.messager.alert('警告','请选择一个权限!');
    }else{
        console.log(selected);
        console.log($('#authorityEditForm').form('load',selected));
        $('#authorityEdit').dialog('open');
    }
">编辑权限</a>
</div>
<div id="authorityAdd" class="easyui-dialog" data-options="closed:true,modal:true" style="width: 250px;height: 300px;">
    <form id="authorityAddForm" method="post">
        <td><input class="easyui-textbox" type="hidden" name="id"></td>
        <table cellpadding="5">
            <tr>
                <td>名称:</td>
                <td><input class="easyui-textbox" type="text" name="name"></td>
            </tr>
            <tr>
                <td>描述:</td>
                <td><input class="easyui-textbox" type="text" name="description"></td>
            </tr>
            <tr>
                <td>方法:</td>
                <td><input class="easyui-textbox" type="text" name="method"></td>
            </tr>
            <tr>
                <td>路径:</td>
                <td><input class="easyui-textbox" type="text" name="url"></td>
            </tr>
            <tr>
                <td>菜单:</td>
                <td>
                    <label><input type="radio" value="true" name="menu">是</label>
                    <label><input type="radio" value="false" name="menu">否</label>
                </td>
            </tr>
        </table>
    </form>
    <div style="text-align:center;padding:5px">
        <a href="javascript:void(0)" class="easyui-linkbutton"
           onclick="$.post('authority',$('#authorityAddForm').serialize(),function(){$('#authorityAdd').dialog('close');$('#authorityTable').datagrid('reload');})">提交</a>
        <a href="javascript:void(0)" class="easyui-linkbutton">重置</a>
    </div>
</div>
<div id="authorityEdit" class="easyui-dialog" data-options="closed:true,modal:true" style="width: 250px;height: 300px;">
    <form id="authorityEditForm" method="post">
        <td><input class="easyui-textbox" type="hidden" name="id"></td>
        <table cellpadding="5">
            <tr>
                <td>名称:</td>
                <td><input class="easyui-textbox" type="text" name="name"></td>
            </tr>
            <tr>
                <td>描述:</td>
                <td><input class="easyui-textbox" type="text" name="description"></td>
            </tr>
            <tr>
                <td>方法:</td>
                <td><input class="easyui-textbox" type="text" name="method"></td>
            </tr>
            <tr>
                <td>路径:</td>
                <td><input class="easyui-textbox" type="text" name="url"></td>
            </tr>
            <tr>
                <td>菜单:</td>
                <td>
                    <label><input type="radio" value="true" name="menu">是</label>
                    <label><input type="radio" value="false" name="menu">否</label>
                </td>
            </tr>

        </table>
    </form>
    <div style="text-align:center;padding:5px">
        <a href="javascript:void(0)" class="easyui-linkbutton"
           onclick="$.put('authority',$('#authorityEditForm').serialize(),function(){$('#authorityEdit').dialog('close');$('#authorityTable').datagrid('reload');})">提交</a>
        <a href="javascript:void(0)" class="easyui-linkbutton">重置</a>
    </div>
</div>
